<script setup lang="ts">
import { useStore } from "@/stores/index";
import { onMounted } from "vue";
import { TestApi, GetDynamicRoutes } from '@/apis/index'
import TheWelcome from '../components/TheWelcome.vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const store = useStore()
onMounted(() => {
  if (store.routes.length < 1) {
    // 获取动态路由
    GetDynamicRoutes().then(res => {
      console.log(res)
      store.addRoutes(res.data.data, router)
    })
  }

  // 测试接口
  TestApi().then(res => console.log(res.data)).catch(err => console.log(err))
})
</script>

<template>
  <main>
    <TheWelcome />
  </main>
</template>
